//
//  WKContenCellRewardView.m
//  WKMaybell
//
//  Created by 何文虎 on 2018/12/5.
//  Copyright © 2018年 何文虎. All rights reserved.
//

#import "WKContenCellRewardView.h"

@interface WKContenCellRewardView ()
@property(nonatomic,strong)UIButton *zanBtn;
@property(nonatomic,strong)UIButton *liwuBtn;
@property(nonatomic,strong)UIButton *commentBtn;
@end

@implementation WKContenCellRewardView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self == [super initWithFrame:frame]) {
        [self setup];
    }
    return self;
}

- (void)setup{
    
    [self wh_addSubviews:@[self.zanBtn,self.liwuBtn,self.commentBtn]];
    
    CGFloat spcontenWidth = (ScreenWidth-24)/3;
    CGFloat width = 45;
    CGFloat height = 18;
    CGFloat spx = (spcontenWidth - width)/2;
    
    
    [self.zanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.width.mas_equalTo(width);
        make.height.mas_equalTo(height);
        make.centerY.mas_equalTo(self.mas_centerY);
    }];
    
    [self.liwuBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12+spcontenWidth+spx);
        make.width.mas_equalTo(width);
        make.height.mas_equalTo(height);
        make.centerY.mas_equalTo(self.mas_centerY);
    }];
    
    [self.commentBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12+spcontenWidth*2+spx);
        make.width.mas_equalTo(width);
        make.height.mas_equalTo(height);
        make.centerY.mas_equalTo(self.mas_centerY);
    }];

    
    
//    _zanBtn.backgroundColor = [UIColor redColor];
    _liwuBtn.backgroundColor = [UIColor redColor];
    _commentBtn.backgroundColor = [UIColor redColor];
    
    [_zanBtn addTarget:self  action:@selector(zanClick:) forControlEvents:UIControlEventTouchUpInside];
    [_commentBtn addTarget:self action:@selector(commentClick:) forControlEvents:UIControlEventTouchUpInside];
    [_liwuBtn addTarget:self action:@selector(liwuClick:) forControlEvents:UIControlEventTouchUpInside];
    
}

#pragma mark - 点赞
- (void)zanClick:(UIButton*)sender{
    sender.selected = !sender.selected;
    if (self.zanBlock) {
        self.zanBlock();
    }
}

#pragma mark - 礼物
- (void)liwuClick:(UIButton*)sender{
    if (self.liwuBlock) {
        self.liwuBlock();
    }
}

#pragma mark - 回复
- (void)commentClick:(UIButton*)sender{
    if (self.commentBlock) {
        self.commentBlock();
    }
}

- (UIButton*)zanBtn{
    if (!_zanBtn) {
        _zanBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _zanBtn.titleLabel.font = PFSC_MediumFont(11);
        [_zanBtn setTitleColor:UIColorFromHex(0x11) forState:UIControlStateNormal];
        [_zanBtn setImage:ImageNamed(@"zan_normal.png") forState:UIControlStateNormal];
        [_zanBtn setImage:ImageNamed(@"zan_selected.png") forState:UIControlStateHighlighted];
        [_zanBtn setImage:ImageNamed(@"zan_selected.png") forState:UIControlStateSelected];
        
    }
     return  _zanBtn;
}

- (UIButton*)liwuBtn{
    if (!_liwuBtn) {
        _liwuBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _liwuBtn.titleLabel.font = PFSC_MediumFont(11);
        [_liwuBtn setTitleColor:UIColorFromHex(0x11) forState:UIControlStateNormal];
        [_liwuBtn setImage:ImageNamed(@"cm_liwu.png") forState:UIControlStateNormal];
    }
   return _liwuBtn;
}

- (UIButton*)commentBtn{
    if (!_commentBtn) {
        _commentBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _commentBtn.titleLabel.font = PFSC_MediumFont(11);
        [_commentBtn setTitleColor:UIColorFromHex(0x11) forState:UIControlStateNormal];
        [_commentBtn setImage:ImageNamed(@"comment_normal.png") forState:UIControlStateNormal];
    }
    return _commentBtn;
}

@end
